#include<bits/stdc++.h>
using namespace std;
int main(){
	vector<int> a, b, c;
	int x;
	while(cin>>x){
		a.push_back(x);
	}
	for(int i = 0;i < a.size();i++){
		int p = lower_bound(b.begin(), b.end(), a[i])-b.begin();
		if(p == b.size())
			b.push_back(a[i]);
		else
			b[p] = a[i];
	}
	
	reverse(a.begin(), a.end());
	for(int i = 0;i < a.size();i++){
		int p = upper_bound(c.begin(), c.end(), a[i])-c.begin();
		if(p == c.size())
			c.push_back(a[i]);
		else
			c[p] = a[i];
	}
	cout<<c.size()<<endl<<b.size();
	return 0;
}
